import React   from 'react';
// dangerouslySetInnerHTML
// 如果要输出html 需要加 dangerouslySetInnerHTML 属性 , 解决其他页面或者后端直接传入html 字符串问题
class App extends React.Component {
    state = {
        myhtml: `
            <div class="top-rated">
               <h1>标题</h1>
            </div>`,
           testHtml:'<div class="top-rated"><h1>标题</h1> </div>'
      };
    
    render() {
        return (
            <div>
                <div
                    dangerouslySetInnerHTML={{
                    __html: this.state.testHtml,
                    }}
                ></div>
                <div>
                 {this.state.myhtml }
                </div>
            </div>
        );
    }
 }

export default App;